package cn.wei.sdd.core.controller.admin;


import cn.wei.common.result.R;
import cn.wei.sdd.base.util.JwtUtils;
import cn.wei.sdd.core.pojo.entity.Orders;
import cn.wei.sdd.core.pojo.entity.User;
import cn.wei.sdd.core.pojo.query.OrdersQuery;
import cn.wei.sdd.core.pojo.vo.ConfirmOrdersVO;
import cn.wei.sdd.core.pojo.vo.OrderStatisticsVO;
import cn.wei.sdd.core.pojo.vo.PlaceOrdersVO;
import cn.wei.sdd.core.pojo.vo.UserOrdersVO;
import cn.wei.sdd.core.service.OrderService;
import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
import com.baomidou.mybatisplus.core.metadata.IPage;
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import io.swagger.annotations.ApiParam;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

import javax.servlet.http.HttpServletRequest;
import java.util.Date;
import java.util.List;

/**
 * <p>
 * 回收订单表 前端控制器
 * </p>
 *
 * @author Wei
 * @since 2021-10-25
 */
@RestController
@Api(tags = "订单管理")
@RequestMapping("/admin/core/order")
public class AdminOrdersController {

    @Autowired
    private OrderService orderService;



    @ApiOperation("获取预约订单列表")
    @GetMapping("subscribeList/{page}/{limit}")
    public R listPage(@ApiParam(value = "当前页码",required = true)
                      @PathVariable("page") Long page,
                      @ApiParam(value = "每页记录数",required = true)
                      @PathVariable("limit") Long limit,
                      @ApiParam(value = "查询对象",required = false)
                      OrdersQuery ordersQuery
                      ){
        Page<Orders> pageParam = new Page<>(page,limit);


     IPage<Orders> pageModel = orderService.listPage(pageParam,ordersQuery);
        return R.ok().data("pageModel",pageModel);
    }


    @ApiOperation("查询当前日期订单统计")
    @GetMapping("getOrderStatistics/{recentTime}")
    public R getOrderStatistics(
            @ApiParam(value = "近期时间",required = true)
            @PathVariable("recentTime") String recentTime
    ){
        System.out.println("recentTime:"+recentTime);
        List<OrderStatisticsVO> list = orderService.getOrderStatisticsByDate(recentTime);
        return R.ok().data("list",list);
    }

    @ApiOperation("查询回收员当前日期接单统计")
    @GetMapping("getRecyclerStatistics/{recentTime}")
    public R getRecyclerStatistics(
            @ApiParam(value = "时间",required = true)
            @PathVariable("recentTime") String recentTime
    ){

        List<OrderStatisticsVO> list = orderService.getRecyclerStatisticsByDate(recentTime);
        return R.ok().data("list",list);
    }


}

